
let id = localStorage.getItem('id')
let showAPI = 'http://jx.xuzhixiang.top/ap/api/productlist.php'
$.get(showAPI, {
    uid:id
}).then(res => {
    let pobj = res.data
    $.each(pobj, function (i, v) {
        let html = `<dl>
    <dt>
        <img src="${v.pimg}" alt="">
    </dt>
    <dd>
        <span class="s1">
            <img src="../img/list-1.png" alt="">
        </span>
        <span class="s2">
            <p>${v.pname}</p>
            <p>${v.pdesc}</p>
        </span>
    </dd>
    <a href="item.html?pid=${v.pid}"><button>入场疯抢&gt;</button></a>
</dl>`
        $(`<dl>${html}</dl>`).appendTo('.inner_c')
    })
})

$('.icon-tuihuodan').mouseenter(function () {
    $('.back').show()
})

$('.icon-tuihuodan').mouseout(function () {
    $('.back').hide()
})

$('.icon-tuihuodan').click(function () {
    document.scrollingElement.scrollTop = 0
})

// 侧边栏购物车数量

let cartAPI = 'http://jx.xuzhixiang.top/ap/api/cart-list.php';

$.get(cartAPI, {
    id,
}).then(res => {
    let pobj = res.data
    let num = 0
    $.each(pobj, function (i, v) {
        num += parseInt($(this).attr('pnum'))
    })
    $('#cart-num').html(num)
})